package com.chenhao.springcloud.chenhaodesignservice.pattern.structural.flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 * Description:
 *
 * @author chenhao
 * @date 2020/12/25 11:17
 */
public class EmployeeFactory {
    private static  final Map <String,Employee> EMPLOYEE_MAP = new HashMap<>();

    public static Employee getManager(String department){
        Manager manager = (Manager) EMPLOYEE_MAP.get(department);
        if (manager==null){
            manager = new Manager(department);
            manager.setReportContent(department+"部门汇报");
            EMPLOYEE_MAP.put(department,manager);
            System.out.println("创建部门经理："+department);
        }
        return manager;
    }
}
